<template>
  <el-col :span="21" :offset="3" class="tag">
    <div>
      <el-tag size="small" closable>小型标签</el-tag>
      <el-tag size="small" closable>小型标签</el-tag>
      <el-tag size="small" closable>小型标签</el-tag>
    </div>
  </el-col>
</template>

<script>
export default {
  data() {
    return {
      editableTabsValue2: "2",
      editableTabs2: [
        {
          title: "Tab 1",
          name: "1",
          content: "Tab 1 content"
        },
        {
          title: "Tab 2",
          name: "2",
          content: "Tab 2 content"
        }
      ],
      tabIndex: 2
    };
  },
  methods: {
    addTab(targetName) {
      let newTabName = ++this.tabIndex + "";
      this.editableTabs2.push({
        title: "New Tab",
        name: newTabName,
        content: "New Tab content"
      });
      this.editableTabsValue2 = newTabName;
    },
    removeTab(targetName) {
      let tabs = this.editableTabs2;
      let activeName = this.editableTabsValue2;
      if (activeName === targetName) {
        tabs.forEach((tab, index) => {
          if (tab.name === targetName) {
            let nextTab = tabs[index + 1] || tabs[index - 1];
            if (nextTab) {
              activeName = nextTab.name;
            }
          }
        });
      }

      this.editableTabsValue2 = activeName;
      this.editableTabs2 = tabs.filter(tab => tab.name !== targetName);
    }
  }
};
</script>

<style scoped>
.tag {
  display: flex;
  height: 4%;
  background: white;
  box-shadow: 0px 2px 5px #888888;
  margin-bottom: 5px;
}
.tag div {
  margin: auto 0px auto 10px;
}
</style>

